package com.smartstate.dataManagement.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartstate.dataManagement.dto.PageDTO;
import com.smartstate.dataManagement.entity.Attribute;
import com.smartstate.dataManagement.entity.Permission;
import com.smartstate.dataManagement.service.AttributeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/Attribute")
public class AttributeController {

    @Resource
    private AttributeService attributeService;

    @PostMapping("/saveOrUpdate")
    @ApiOperation(value = "新增或修改")
    public boolean saveOrUpdate(@RequestBody Attribute attribute) {
        return attributeService.saveOrUpdate(attribute);
    }

    @PostMapping("/removeByIds")
    @ApiOperation(value = "根据ID批量删除")
    public boolean removeByIds(@RequestBody List<Attribute> item) {
        return attributeService.removeByIds(item);
    }

    @PostMapping("/removeById")
    @ApiOperation(value = "根据ID删除")
    public boolean removeById(@RequestParam Integer id) {
        return attributeService.removeById(id);
    }

    @GetMapping("/getById")
    @ApiOperation(value = "根据ID查询")
    public Attribute getById(@RequestParam Integer id){
        return attributeService.getById(id);
    }


    @PostMapping("/getAttributeBySpec")
    @ApiOperation(value = "单表分页查询")
    public Page<Attribute> getUserBySpec(@RequestBody PageDTO<Attribute> pageDTO) {
        return attributeService.queryAllPageByDTO(pageDTO);
    }

    @GetMapping("/findAll")
    @ApiOperation(value = "新增或修改")
    public List<Attribute> findAll() {
        return attributeService.findAll();
    }

}